#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <unistd.h>
class Test {
    public:
        Test() { std::cout << "构造" << std::endl; }
        ~Test() { std::cout << "析构" << std::endl; }
};

void del(const Test *t, int num) {
    std::cout << num << std::endl;
    delete t;
}
/*
int main()
{
    Test *t = new Test;
    //bind作用其实就是给一个函数绑定好参数，然后返回一个参数已经设定好的函数，可以在合适的时候进行调用
    std::function<void(int)> cb = std::bind(del, t, std::placeholders::_1);
    cb(10); 
    while(1) sleep(1);
    return 0;
}
*/
void print(const std::string &str) {
    std::cout << str << std::endl;
}

int main()
{
    using Functor = std::function<void()>;
    std::vector<Functor> task_pool;

    task_pool.push_back(std::bind(print, "比特"));
    task_pool.push_back(std::bind(print, "你好"));
    task_pool.push_back(std::bind(print, "我是"));
    task_pool.push_back(std::bind(print, "好学生"));

    for (auto &functor : task_pool) {
        functor();
    }
    return 0;
}